import json
# 定义 UserInfo 类
class UserInfo:
    def __init__(self, name, age, email):
        self.name = name
        self.age = age
        self.email = email
    def __str__(self):
        return f"Name: {self.name}, Age: {self.age}, Email: {self.email}"
# 读取 json.txt 文件中的信息
def read_json_file(filename):
    with open(filename, 'r') as file:
        return json.load(file)
# 将 JSON 数据封装为 UserInfo 对象并存入列表
def create_user_list(json_data):
    user_list = []
    for user in json_data:
        user_list.append(UserInfo(**user))
    return user_list
# 主函数
def main():
    json_data = read_json_file('json.txt')
    users = create_user_list(json_data)
    # 遍历列表并输出所有用户信息
    for user in users:
        print(user)
if __name__ == "__main__":
    main()
